11 / 13

Why can cosine similarity and dot product rank unnormalized embeddings differently?

Normalization changes the meaning of dot product

Cosine similarity is the dot product divided by the product of the two vector magnitudes. Therefore cosine removes vector-length effects and compares direction, while raw dot product includes both direction and magnitude.

If two vectors are not unit-normalized, a vector with a large norm can receive a high dot-product score even when its direction is not the best match. Cosine can rank that same vector lower because it ignores magnitude.

The trade-off is semantic intent. If vector magnitude carries useful information learned by the model, dot product can be the correct metric. If magnitude is mostly an artifact and direction represents similarity, cosine is usually more appropriate.

In current Qdrant implementations, cosine vectors are normalized for efficient comparison, effectively allowing the distance calculation to use dot product after normalization. Do not infer from that that raw dot-product and cosine are equivalent for arbitrary unnormalized vectors; they are equivalent in ranking only when the vectors are unit-normalized.

javascript
  1. 1

    Cosine divides the dot product by vector magnitudes

  2. 2

    Raw dot product can favor high-norm vectors

  3. 3

    Unit-normalized vectors produce the same ranking under cosine and dot product

  4. 4

    Metric choice should reflect whether vector magnitude carries useful signal

Difficulty: 5/10
Topics: Distance metrics, Vector normalization

Scenario Questions

0-2 years experience
  1. 1

    Two vectors have identical direction but different magnitudes. Why can their dot-product scores differ while cosine scores remain equal?

  2. 2

    A teammate switches a collection from cosine to dot product without checking vector normalization. What bug could appear?

2-5 years experience
  1. 1

    Search results become biased toward long documents after changing the metric to dot product. What would you inspect in the embedding vectors?

  2. 2

    You discover that all vectors are already unit-normalized. What practical implication does that have for choosing cosine versus dot product?

5-8 years experience
  1. 1

    A model vendor says vector magnitude contains useful confidence information. How would that affect your metric choice and evaluation design?

  2. 2

    You migrate embeddings between two systems and the top-k rankings differ even though the vectors appear identical. How would you isolate normalization and metric differences?

8+ years experience
  1. 1

    Your retrieval system combines embedding models whose vector norms have different distributions. How would you prevent norm differences from creating unintended ranking bias?

  2. 2

    A product team wants to use dot product because it is faster, while relevance engineers prefer cosine. How would you determine whether magnitude is meaningful enough to justify dot product?

Follow-up Questions

  • Why might an embedding model intentionally encode information in vector magnitude?
  • How would you diagnose a ranking change after switching from cosine to dot product?